package com.wym.lottery.ui;

import com.wym.lottery.adapter.DataBaseExpandableListAdapter;
import com.wym.lottery.model.Bill;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.SimpleExpandableListAdapter;

public class HistoryBillFragment extends Fragment {

	private static int sectionID;
	private ExpandableListView exlv;

	public static HistoryBillFragment newInstance(int sectionNumber) {
		sectionID = sectionNumber;
		HistoryBillFragment historyBillFragment = new HistoryBillFragment();
		return historyBillFragment;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

		View rootView = inflater.inflate(R.layout.fragment_history_bill, container, false);

		exlv = (ExpandableListView) rootView.findViewById(R.id.exlv_history_bill);
		Bill[] group = new Bill[] { new Bill("1500", "", "111", "222"), new Bill("1500", "", "333", "444") };
		Bill[][] child = new Bill[][] { { new Bill("1500", "四码", "555", "666"), new Bill("1500", "三定", "777", "888") }, { new Bill("1500", "四现", "999", "000"), new Bill("1500", "三现", "1212", "1313") } };

		DataBaseExpandableListAdapter adapter = new DataBaseExpandableListAdapter(getActivity(), R.layout.bill_item, group, child);
		exlv.setAdapter(adapter);

		return rootView;
	}

	@Override
	public void onAttach(Activity activity) {
		((MainActivity) activity).onSectionAttached(sectionID);
		super.onAttach(activity);
	}
}
